Partition Array into Disjoint Intervals C